#include "videoconfigwidget.h"

VideoConfigWidget::VideoConfigWidget(int videoMode, QWidget *parent) : QWidget(parent),
    m_VideoMode(videoMode)
{
    m_gridLayout = new QGridLayout(this);

    displayLabel = new QLabel("显示模式设置", this);
    displayCom = new QComboBox(this);

    QStringList comItems = {"单显", "双显", "四显"};
    displayCom->addItems(comItems);

    resourcesName_1 = new QLabel("视频源名称", this);
    resourcesName_2 = new QLabel("视频源名称", this);
    resourcesName_3 = new QLabel("视频源名称", this);
    resourcesName_4 = new QLabel("视频源名称", this);

    resourcesNameLine_1 = new QLineEdit(this);
    resourcesNameLine_2 = new QLineEdit(this);
    resourcesNameLine_3 = new QLineEdit(this);
    resourcesNameLine_4 = new QLineEdit(this);

    QStringList ipComItems = {"单播绑定IP", "组播绑定IP", "广播绑定IP"};

    ipCom_1 = new QComboBox(this);
    ipCom_2 = new QComboBox(this);
    ipCom_3 = new QComboBox(this);
    ipCom_4 = new QComboBox(this);

    ipCom_1->addItems(ipComItems);
    ipCom_2->addItems(ipComItems);
    ipCom_3->addItems(ipComItems);
    ipCom_4->addItems(ipComItems);

    ipLine_1 = new QLineEdit(this);
    ipLine_2 = new QLineEdit(this);
    ipLine_3 = new QLineEdit(this);
    ipLine_4 = new QLineEdit(this);

    port_1 = new QLabel("绑定端口号", this);
    port_2 = new QLabel("绑定端口号", this);
    port_3 = new QLabel("绑定端口号", this);
    port_4 = new QLabel("绑定端口号", this);

    portSpinBox_1 = new QSpinBox(this);
    portSpinBox_1->setRange(1, 65535);
    portSpinBox_2 = new QSpinBox(this);
    portSpinBox_2->setRange(1, 65535);
    portSpinBox_3 = new QSpinBox(this);
    portSpinBox_3->setRange(1, 65535);
    portSpinBox_4 = new QSpinBox(this);
    portSpinBox_4->setRange(1, 65535);

    m_srcIPLabel_1 = new QLabel("源IP", this);
    m_srcIPLabel_2 = new QLabel("源IP", this);
    m_srcIPLabel_3 = new QLabel("源IP", this);
    m_srcIPLabel_4 = new QLabel("源IP", this);

    m_srcIPLine_1 = new QLineEdit(this);
    m_srcIPLine_2 = new QLineEdit(this);
    m_srcIPLine_3 = new QLineEdit(this);
    m_srcIPLine_4 = new QLineEdit(this);
    m_srcIPLine_1->setReadOnly(true);
    m_srcIPLine_2->setReadOnly(true);
    m_srcIPLine_3->setReadOnly(true);
    m_srcIPLine_4->setReadOnly(true);

    //分辨率
    m_solutionLabel_1 = new QLabel("分辨率" , this);
    m_solutionLabel_2 = new QLabel("分辨率" , this);
    m_solutionLabel_3 = new QLabel("分辨率" , this);
    m_solutionLabel_4 = new QLabel("分辨率" , this);

    m_solutionLine_1 = new QLineEdit(this);
    m_solutionLine_2 = new QLineEdit(this);
    m_solutionLine_3 = new QLineEdit(this);
    m_solutionLine_4 = new QLineEdit(this);
    m_solutionLine_1->setReadOnly(true);
    m_solutionLine_2->setReadOnly(true);
    m_solutionLine_3->setReadOnly(true);
    m_solutionLine_4->setReadOnly(true);

    //帧率
    m_fpsLabel_1 = new QLabel("帧率" , this);
    m_fpsLabel_2 = new QLabel("帧率" , this);
    m_fpsLabel_3 = new QLabel("帧率" , this);
    m_fpsLabel_4 = new QLabel("帧率" , this);

    m_fpsLine_1 = new QLineEdit(this);
    m_fpsLine_2 = new QLineEdit(this);
    m_fpsLine_3 = new QLineEdit(this);
    m_fpsLine_4 = new QLineEdit(this);
    m_fpsLine_1->setReadOnly(true);
    m_fpsLine_2->setReadOnly(true);
    m_fpsLine_3->setReadOnly(true);
    m_fpsLine_4->setReadOnly(true);

    //编码格式
    m_codeLabel_1 = new QLabel("编码格式" , this);
    m_codeLabel_2 = new QLabel("编码格式" , this);
    m_codeLabel_3 = new QLabel("编码格式" , this);
    m_codeLabel_4 = new QLabel("编码格式" , this);

    m_codeLine_1 = new QLineEdit(this);
    m_codeLine_2 = new QLineEdit(this);
    m_codeLine_3 = new QLineEdit(this);
    m_codeLine_4 = new QLineEdit(this);
    m_codeLine_1->setReadOnly(true);
    m_codeLine_2->setReadOnly(true);
    m_codeLine_3->setReadOnly(true);
    m_codeLine_4->setReadOnly(true);

    m_netCardLabel_1 = new QLabel("网卡", this);
    m_netCardLabel_2 = new QLabel("网卡", this);
    m_netCardLabel_3 = new QLabel("网卡", this);
    m_netCardLabel_4 = new QLabel("网卡", this);

    m_netCardComb_1 = new QComboBox(this);
    m_netCardComb_2 = new QComboBox(this);
    m_netCardComb_3 = new QComboBox(this);
    m_netCardComb_4 = new QComboBox(this);

    update_1 = new QPushButton("更新");
    update_2 = new QPushButton("更新");
    update_3 = new QPushButton("更新");
    update_4 = new QPushButton("更新");

    m_gridLayout->addWidget(displayLabel, 0, 0, 1, 1);
    m_gridLayout->addWidget(displayCom, 0, 1, 1, 1);

    displayCom->setMinimumSize(100, 30);

    m_VideoMode = 2;

    addLayout();
    displayCom->setCurrentIndex(m_VideoMode);//默认设置1显
    onCurrentIndexChanged(m_VideoMode);   //默认设置1显模式
    controlConnect();           //连接信号和槽
    showNetCard();

    connect(displayCom, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &VideoConfigWidget::onCurrentIndexChanged);
}

void VideoConfigWidget::addLayout()
{
    //第一行
    m_gridLayout->addWidget(resourcesName_1, 1, 0, 1, 1);
    m_gridLayout->addWidget(resourcesNameLine_1, 1, 1, 1, 1);
    m_gridLayout->addWidget(ipCom_1, 1, 2, 1, 1);
    m_gridLayout->addWidget(ipLine_1, 1, 3, 1, 1);
    m_gridLayout->addWidget(port_1, 1, 4, 1, 1);
    m_gridLayout->addWidget(portSpinBox_1, 1, 5, 1, 1);
    m_gridLayout->addWidget(m_srcIPLabel_1, 1, 6, 1, 1);
    m_gridLayout->addWidget(m_srcIPLine_1, 1, 7, 1, 1);
    m_gridLayout->addWidget(m_solutionLabel_1, 1, 8, 1, 1);
    m_gridLayout->addWidget(m_solutionLine_1, 1, 9, 1, 1);
    m_gridLayout->addWidget(m_fpsLabel_1, 1, 10, 1, 1);
    m_gridLayout->addWidget(m_fpsLine_1, 1, 11, 1, 1);
    m_gridLayout->addWidget(m_codeLabel_1, 1, 12, 1, 1);
    m_gridLayout->addWidget(m_codeLine_1, 1, 13, 1, 1);
    m_gridLayout->addWidget(m_netCardLabel_1, 1, 14, 1, 1);
    m_gridLayout->addWidget(m_netCardComb_1, 1, 15, 1, 1);
    m_gridLayout->addWidget(update_1, 1, 16, 1, 1);

    //只要设置第一行就行了，因为第一行一直都显示，其余行会自动适应
    resourcesNameLine_1->setMinimumSize(100, 30);
    ipLine_1->setMinimumSize(100, 30);
    portSpinBox_1->setMinimumSize(100, 30);
    m_srcIPLine_1->setMinimumSize(150, 30);
    m_solutionLine_1->setMinimumSize(150, 30);
    m_fpsLine_1->setMinimumSize(150, 30);
    m_codeLine_1->setMinimumSize(150, 30);

    //第二行
    m_gridLayout->addWidget(resourcesName_2, 2, 0, 1, 1);
    m_gridLayout->addWidget(resourcesNameLine_2, 2, 1, 1, 1);
    m_gridLayout->addWidget(ipCom_2, 2, 2, 1, 1);
    m_gridLayout->addWidget(ipLine_2, 2, 3, 1, 1);
    m_gridLayout->addWidget(port_2, 2, 4, 1, 1);
    m_gridLayout->addWidget(portSpinBox_2, 2, 5, 1, 1);
    m_gridLayout->addWidget(m_srcIPLabel_2, 2, 6, 1, 1);
    m_gridLayout->addWidget(m_srcIPLine_2, 2, 7, 1, 1);
    m_gridLayout->addWidget(m_solutionLabel_2, 2, 8, 1, 1);
    m_gridLayout->addWidget(m_solutionLine_2, 2, 9, 1, 1);
    m_gridLayout->addWidget(m_fpsLabel_2, 2, 10, 1, 1);
    m_gridLayout->addWidget(m_fpsLine_2, 2, 11, 1, 1);
    m_gridLayout->addWidget(m_codeLabel_2, 2, 12, 1, 1);
    m_gridLayout->addWidget(m_codeLine_2, 2, 13, 1, 1);
    m_gridLayout->addWidget(m_netCardLabel_2, 2, 14, 1, 1);
    m_gridLayout->addWidget(m_netCardComb_2, 2, 15, 1, 1);
    m_gridLayout->addWidget(update_2, 2, 16, 1, 1);

    //第三行
    m_gridLayout->addWidget(resourcesName_3, 3, 0, 1, 1);
    m_gridLayout->addWidget(resourcesNameLine_3, 3, 1, 1, 1);
    m_gridLayout->addWidget(ipCom_3, 3, 2, 1, 1);
    m_gridLayout->addWidget(ipLine_3, 3, 3, 1, 1);
    m_gridLayout->addWidget(port_3, 3, 4, 1, 1);
    m_gridLayout->addWidget(portSpinBox_3, 3, 5, 1, 1);
    m_gridLayout->addWidget(m_srcIPLabel_3, 3, 6, 1, 1);
    m_gridLayout->addWidget(m_srcIPLine_3, 3, 7, 1, 1);
    m_gridLayout->addWidget(m_solutionLabel_3, 3, 8, 1, 1);
    m_gridLayout->addWidget(m_solutionLine_3, 3, 9, 1, 1);
    m_gridLayout->addWidget(m_fpsLabel_3, 3, 10, 1, 1);
    m_gridLayout->addWidget(m_fpsLine_3, 3, 11, 1, 1);
    m_gridLayout->addWidget(m_codeLabel_3, 3, 12, 1, 1);
    m_gridLayout->addWidget(m_codeLine_3, 3, 13, 1, 1);
    m_gridLayout->addWidget(m_netCardLabel_3, 3, 14, 1, 1);
    m_gridLayout->addWidget(m_netCardComb_3, 3, 15, 1, 1);
    m_gridLayout->addWidget(update_3, 3, 16, 1, 1);

    //第四行
    m_gridLayout->addWidget(resourcesName_4, 4, 0, 1, 1);
    m_gridLayout->addWidget(resourcesNameLine_4, 4, 1, 1, 1);
    m_gridLayout->addWidget(ipCom_4, 4, 2, 1, 1);
    m_gridLayout->addWidget(ipLine_4, 4, 3, 1, 1);
    m_gridLayout->addWidget(port_4, 4, 4, 1, 1);
    m_gridLayout->addWidget(portSpinBox_4, 4, 5, 1, 1);
    m_gridLayout->addWidget(m_srcIPLabel_4, 4, 6, 1, 1);
    m_gridLayout->addWidget(m_srcIPLine_4, 4, 7, 1, 1);
    m_gridLayout->addWidget(m_solutionLabel_4, 4, 8, 1, 1);
    m_gridLayout->addWidget(m_solutionLine_4, 4, 9, 1, 1);
    m_gridLayout->addWidget(m_fpsLabel_4, 4, 10, 1, 1);
    m_gridLayout->addWidget(m_fpsLine_4, 4, 11, 1, 1);
    m_gridLayout->addWidget(m_codeLabel_4, 4, 12, 1, 1);
    m_gridLayout->addWidget(m_codeLine_4, 4, 13, 1, 1);
    m_gridLayout->addWidget(m_netCardLabel_4, 4, 14, 1, 1);
    m_gridLayout->addWidget(m_netCardComb_4, 4, 15, 1, 1);
    m_gridLayout->addWidget(update_4, 4, 16, 1, 1);
}

void VideoConfigWidget::singleShowMode()
{
    resourcesName_2->hide();
    resourcesName_3->hide();
    resourcesName_4->hide();

    resourcesNameLine_2->hide();
    resourcesNameLine_3->hide();
    resourcesNameLine_4->hide();

    ipCom_2->hide();
    ipCom_3->hide();
    ipCom_4->hide();

    ipLine_2->hide();
    ipLine_3->hide();
    ipLine_4->hide();

    port_2->hide();
    port_3->hide();
    port_4->hide();

    portSpinBox_2->hide();
    portSpinBox_3->hide();
    portSpinBox_4->hide();

    m_srcIPLabel_2->hide();
    m_srcIPLabel_3->hide();
    m_srcIPLabel_4->hide();

    m_srcIPLine_2->hide();
    m_srcIPLine_3->hide();
    m_srcIPLine_4->hide();

    m_solutionLabel_2->hide();
    m_solutionLabel_3->hide();
    m_solutionLabel_4->hide();

    m_solutionLine_2->hide();
    m_solutionLine_3->hide();
    m_solutionLine_4->hide();

    m_fpsLabel_2->hide();
    m_fpsLabel_3->hide();
    m_fpsLabel_4->hide();

    m_fpsLine_2->hide();
    m_fpsLine_3->hide();
    m_fpsLine_4->hide();

    m_codeLabel_2->hide();
    m_codeLabel_3->hide();
    m_codeLabel_4->hide();

    m_codeLine_2->hide();
    m_codeLine_3->hide();
    m_codeLine_4->hide();

    m_netCardLabel_2->hide();
    m_netCardLabel_3->hide();
    m_netCardLabel_4->hide();

    m_netCardComb_2->hide();
    m_netCardComb_3->hide();
    m_netCardComb_4->hide();

    update_2->hide();
    update_3->hide();
    update_4->hide();
}

void VideoConfigWidget::TwoShowMode()
{
    resourcesName_2->show();
    resourcesName_3->hide();
    resourcesName_4->hide();

    resourcesNameLine_2->show();
    resourcesNameLine_3->hide();
    resourcesNameLine_4->hide();

    ipCom_2->show();
    ipCom_3->hide();
    ipCom_4->hide();

    ipLine_2->show();
    ipLine_3->hide();
    ipLine_4->hide();

    port_2->show();
    port_3->hide();
    port_4->hide();

    portSpinBox_2->show();
    portSpinBox_3->hide();
    portSpinBox_4->hide();

    m_srcIPLabel_2->show();
    m_srcIPLabel_3->hide();
    m_srcIPLabel_4->hide();

    m_srcIPLine_2->show();
    m_srcIPLine_3->hide();
    m_srcIPLine_4->hide();

    m_solutionLabel_2->show();
    m_solutionLabel_3->hide();
    m_solutionLabel_4->hide();

    m_solutionLine_2->show();
    m_solutionLine_3->hide();
    m_solutionLine_4->hide();

    m_fpsLabel_2->show();
    m_fpsLabel_3->hide();
    m_fpsLabel_4->hide();

    m_fpsLine_2->show();
    m_fpsLine_3->hide();
    m_fpsLine_4->hide();

    m_codeLabel_2->show();
    m_codeLabel_3->hide();
    m_codeLabel_4->hide();

    m_codeLine_2->show();
    m_codeLine_3->hide();
    m_codeLine_4->hide();

    m_netCardLabel_2->show();
    m_netCardLabel_3->hide();
    m_netCardLabel_4->hide();

    m_netCardComb_2->show();
    m_netCardComb_3->hide();
    m_netCardComb_4->hide();

    update_2->show();
    update_3->hide();
    update_4->hide();
}

void VideoConfigWidget::FourShowMode()
{
    resourcesName_2->show();
    resourcesName_3->show();
    resourcesName_4->show();

    resourcesNameLine_2->show();
    resourcesNameLine_3->show();
    resourcesNameLine_4->show();

    ipCom_2->show();
    ipCom_3->show();
    ipCom_4->show();

    ipLine_2->show();
    ipLine_3->show();
    ipLine_4->show();

    port_2->show();
    port_3->show();
    port_4->show();

    portSpinBox_2->show();
    portSpinBox_3->show();
    portSpinBox_4->show();

    m_srcIPLabel_2->show();
    m_srcIPLabel_3->show();
    m_srcIPLabel_4->show();

    m_srcIPLine_2->show();
    m_srcIPLine_3->show();
    m_srcIPLine_4->show();

    m_solutionLabel_2->show();
    m_solutionLabel_3->show();
    m_solutionLabel_4->show();

    m_solutionLine_2->show();
    m_solutionLine_3->show();
    m_solutionLine_4->show();

    m_fpsLabel_2->show();
    m_fpsLabel_3->show();
    m_fpsLabel_4->show();

    m_fpsLine_2->show();
    m_fpsLine_3->show();
    m_fpsLine_4->show();

    m_codeLabel_2->show();
    m_codeLabel_3->show();
    m_codeLabel_4->show();

    m_codeLine_2->show();
    m_codeLine_3->show();
    m_codeLine_4->show();

    m_netCardLabel_2->show();
    m_netCardLabel_3->show();
    m_netCardLabel_4->show();

    m_netCardComb_2->show();
    m_netCardComb_3->show();
    m_netCardComb_4->show();

    update_2->show();
    update_3->show();
    update_4->show();
}

void VideoConfigWidget::controlConnect()
{
    connect(resourcesNameLine_1, &QLineEdit::editingFinished, this, &VideoConfigWidget::onVideoCfgChanged_1);
    connect(resourcesNameLine_2, &QLineEdit::editingFinished, this, &VideoConfigWidget::onVideoCfgChanged_2);
    connect(resourcesNameLine_3, &QLineEdit::editingFinished, this, &VideoConfigWidget::onVideoCfgChanged_3);
    connect(resourcesNameLine_4, &QLineEdit::editingFinished, this, &VideoConfigWidget::onVideoCfgChanged_4);

    connect(ipLine_1, &QLineEdit::editingFinished, this, &VideoConfigWidget::onVideoCfgChanged_1);
    connect(ipLine_2, &QLineEdit::editingFinished, this, &VideoConfigWidget::onVideoCfgChanged_2);
    connect(ipLine_3, &QLineEdit::editingFinished, this, &VideoConfigWidget::onVideoCfgChanged_3);
    connect(ipLine_4, &QLineEdit::editingFinished, this, &VideoConfigWidget::onVideoCfgChanged_4);

    connect(portSpinBox_1, &QSpinBox::editingFinished, this, &VideoConfigWidget::onVideoCfgChanged_1);
    connect(portSpinBox_2, &QSpinBox::editingFinished, this, &VideoConfigWidget::onVideoCfgChanged_2);
    connect(portSpinBox_3, &QSpinBox::editingFinished, this, &VideoConfigWidget::onVideoCfgChanged_3);
    connect(portSpinBox_4, &QSpinBox::editingFinished, this, &VideoConfigWidget::onVideoCfgChanged_4);

    connect(m_netCardComb_1, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &VideoConfigWidget::onNetCardChanged_1);
    connect(m_netCardComb_2, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &VideoConfigWidget::onNetCardChanged_2);
    connect(m_netCardComb_3, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &VideoConfigWidget::onNetCardChanged_3);
    connect(m_netCardComb_4, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &VideoConfigWidget::onNetCardChanged_4);

    connect(update_1, &QPushButton::clicked, [=]{
        sigClick(0);
    });
    connect(update_2, &QPushButton::clicked, [=]{
        sigClick(1);
    });
    connect(update_3, &QPushButton::clicked, [=]{
        sigClick(2);
    });
    connect(update_4, &QPushButton::clicked, [=]{
        sigClick(3);
    });

    connect(ipCom_1, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &VideoConfigWidget::onIpCom_1Changed);
    connect(ipCom_1, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &VideoConfigWidget::onIpCom_2Changed);
    connect(ipCom_1, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &VideoConfigWidget::onIpCom_3Changed);
    connect(ipCom_1, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &VideoConfigWidget::onIpCom_4Changed);
}

void VideoConfigWidget::onCurrentIndexChanged(int index)
{
    //清空布局
    singleShowMode();
    m_VideoMode = index;

    //重新布局
    switch(index) {
        case 0: {
            singleShowMode();
            emit sigChangedDisplayMode(1);
            break;
        }
        case 1: {
            TwoShowMode();
            emit sigChangedDisplayMode(2);
            break;
        }
        case 2: {
            FourShowMode();
            emit sigChangedDisplayMode(4);
            break;
        }
        default: break;
    }
}

void VideoConfigWidget::onVideoCfgChanged_1()
{
    WINDOW_CONFIG m_sendConfig;
    m_sendConfig.ip = ipLine_1->text();
    m_sendConfig.port = portSpinBox_1->text().toInt();
    m_sendConfig.resourcesName = resourcesNameLine_1->text();
    m_sendConfig.videoNum = 0;
    m_sendConfig.netCard = m_netCardComb_1->currentText();
    m_sendConfig.bindWay = ipCom_1->currentIndex();

    emit sigVideoChanged(m_sendConfig);
}

void VideoConfigWidget::onVideoCfgChanged_2()
{
    WINDOW_CONFIG m_sendConfig;
    m_sendConfig.ip = ipLine_2->text();
    m_sendConfig.port = portSpinBox_2->text().toInt();
    m_sendConfig.resourcesName = resourcesNameLine_2->text();
    m_sendConfig.videoNum = 1;
    m_sendConfig.netCard = m_netCardComb_2->currentText();
    m_sendConfig.bindWay = ipCom_2->currentIndex();
    emit sigVideoChanged(m_sendConfig);
}

void VideoConfigWidget::onVideoCfgChanged_3()
{
    WINDOW_CONFIG m_sendConfig;
    m_sendConfig.ip = ipLine_3->text();
    m_sendConfig.port = portSpinBox_3->text().toInt();
    m_sendConfig.resourcesName = resourcesNameLine_3->text();
    m_sendConfig.videoNum = 2;
    m_sendConfig.netCard = m_netCardComb_3->currentText();
    m_sendConfig.bindWay = ipCom_3->currentIndex();
    emit sigVideoChanged(m_sendConfig);
}

void VideoConfigWidget::onVideoCfgChanged_4()
{
    WINDOW_CONFIG m_sendConfig;
    m_sendConfig.ip = ipLine_4->text();
    m_sendConfig.port = portSpinBox_4->text().toInt();
    m_sendConfig.resourcesName = resourcesNameLine_4->text();
    m_sendConfig.videoNum = 3;
    m_sendConfig.netCard = m_netCardComb_4->currentText();
    m_sendConfig.bindWay = ipCom_4->currentIndex();
    emit sigVideoChanged(m_sendConfig);
}

void VideoConfigWidget::onNetCardChanged_1(int index)
{
    onVideoCfgChanged_1();
}

void VideoConfigWidget::onNetCardChanged_2(int index)
{
    onVideoCfgChanged_2();
}

void VideoConfigWidget::onNetCardChanged_3(int index)
{
    onVideoCfgChanged_3();
}

void VideoConfigWidget::onNetCardChanged_4(int index)
{
    onVideoCfgChanged_4();
}

//udp接收绑定方式更改
void VideoConfigWidget::onIpCom_1Changed(int index)
{
    onVideoCfgChanged_1();
}

//udp接收绑定方式更改
void VideoConfigWidget::onIpCom_2Changed(int index)
{
    onVideoCfgChanged_2();
}

//udp接收绑定方式更改
void VideoConfigWidget::onIpCom_3Changed(int index)
{
    onVideoCfgChanged_3();
}

//udp接收绑定方式更改
void VideoConfigWidget::onIpCom_4Changed(int index)
{
    onVideoCfgChanged_4();
}

void VideoConfigWidget::changeVideoComb(int index)
{
    if(index == 1) {
        displayCom->setCurrentIndex(0);
    } else if(index == 2) {
        displayCom->setCurrentIndex(1);
    } else if(index == 4) {
        displayCom->setCurrentIndex(2);
    }
}

void VideoConfigWidget::showIPInfo(int videoID, QString ipSrc)
{
    switch (videoID) {
    case 0:
        m_srcIPLine_1->setText(ipSrc);
        break;
    case 1:
        m_srcIPLine_2->setText(ipSrc);
        break;
    case 2:
        m_srcIPLine_3->setText(ipSrc);
        break;
    case 3:
        m_srcIPLine_4->setText(ipSrc);
        break;
    default:
        break;
    }
}

void VideoConfigWidget::showNetCard()
{
    QList<QNetworkInterface> list = QNetworkInterface::allInterfaces();  //多网卡情况
    for(auto intf : list){
        if(intf.name() == "lo" || intf.name().contains("can")) {
            continue;
        }
        m_netCards.append(intf.name());
        //qInfo() << "inf name:" << intf.humanReadableName() << intf.name();
    }

    if(list.size() == 0) {
        qDebug() << "没有找到网卡";
        return;
    }

    for(int i = 0; i < m_netCards.size(); i++) {
        m_netCardComb_1->addItem(m_netCards[i]);
        m_netCardComb_2->addItem(m_netCards[i]);
        m_netCardComb_3->addItem(m_netCards[i]);
        m_netCardComb_4->addItem(m_netCards[i]);
    }
}

void VideoConfigWidget::showSolution(int videoID, int width, int height)
{
    QString value = QString::number(width * height);
    switch (videoID) {
    case 0:
        m_solutionLine_1->setText(value);
        break;
    case 1:
        m_solutionLine_2->setText(value);
        break;
    case 2:
        m_solutionLine_3->setText(value);
        break;
    case 3:
        m_solutionLine_4->setText(value);
        break;
    default:
        break;
    }
}

void VideoConfigWidget::showFPS(int videoID, int fps)
{
    switch (videoID) {
    case 0:
        m_fpsLine_1->setText(QString::number(fps));
        break;
    case 1:
        m_fpsLine_2->setText(QString::number(fps));
        break;
    case 2:
        m_fpsLine_3->setText(QString::number(fps));
        break;
    case 3:
        m_fpsLine_4->setText(QString::number(fps));
        break;
    default:
        break;
    }
}

void VideoConfigWidget::showEncodeForm(int videoID, QString form)
{
    switch (videoID) {
    case 0:
        m_codeLine_1->setText(form);
        break;
    case 1:
        m_codeLine_2->setText(form);
        break;
    case 2:
        m_codeLine_3->setText(form);
        break;
    case 3:
        m_codeLine_4->setText(form);
        break;
    default:
        break;
    }
}





